/*=================================================================================
 * Class Mesh:	Class for mesh processing
 *				Read file -> Intialization -> Set boundary -> Check
 *=================================================================================*/

#ifndef MESH_H
#define MESH_H

/*---------------------------------------------------------------------------------
 * Standard C++ library headers
 *---------------------------------------------------------------------------------*/

#include <algorithm>
#include <iostream>

/*---------------------------------------------------------------------------------
 * Local headers
 *---------------------------------------------------------------------------------*/
#include "Array.h"

using namespace std;

class Mesh
{
private:
	/* x axis */
	int total_ni;                            /* Number of total nodes*/
	int ni;									/* Number of nodes */
	double total_xa,xa;								/* The start point */
	double total_xb,xb;								/* The end point */
	Array<double> xnode,total_xnode;					/* The mesh nodes */
	double dx;								/* The mesh spacing */

	/* y axis */
	int total_nj;                           /*Number of total nodes*/
	int nj;									/* The number of mesh nodes */
	int local_nj ;                          /*The number of mesh nodes in a processor*/
	double total_ya,ya;								/* The start point */
	double total_yb,yb;								/* The end point */
	Array<double> ynode,total_ynode;					/* The mesh nodes */
	double dy;								/* The mesh spacing */

	int bc;									/* The number of each boundary grid */

public:

	friend class Euler;                    /* Friend class -> access to use private object */

	/* Constructor */
	Mesh() =default;

	/* Read the grid file */
	void MeshProcess(char* gridname);
	void MeshProcess_MPI(int MPI_ID,int MPI_SIZE,char* gridname);

	/* Mesh Initialization */
	void Initial();

	/* Mesh boundary */
	void Boundary();

	/* Check the grid file */
	void MeshCheck();
	void MeshCheck_MPI(int id);
	void TotMeshCheck();

	/* Destructor */
	~Mesh() { ; };

	/* Get the mesh nodes */
	Array<double> GetXnode();
	Array<double> GetYnode();

};
#endif